<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>返回两个⽇期之间相差的天数</title>
</head>
<body>
    <script>
        function num(time){
            var nowTime =new Date('2022-10-12 16:10:12')//返回的时当前的毫秒数
            var inp =new Date(time)//返回的是用户输入时间总的毫秒数
            var times =(inp-nowTime)/1000 //times剩余的毫秒数
            p1 =parseInt(times/60/60/24)
            p2=parseInt(times/60/60%24)
            p3=parseInt(times/60%60)
            p4=parseInt(times%60)
            return p1+'天'+p2+'时'+p3+'分'+p4+'秒'
        }
        console.log(num('2022-11-12 16:10:22'))
    </script>
</body>
</html>